<template>
  <div class="spanControl-list" style="width: 100%;margin-left: 0!important;">
    <el-card class="box-card card-head" style="margin: 0px; width: 100%; min-height: 99%">
      <div slot="header" class="clearfix">
        <span>注册审核详情</span>
      </div>

      <div class="text item">
        <el-form label-position="left" inline class="display-form" v-if="businessRegistration.business!=undefined">
          <!--<el-form-item label="名称">-->
          <!--<span>{{ businessRegistration.name }}</span>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="商家">-->
          <!--<span>{{ businessRegistration.businessId }}</span>-->
          <!--</el-form-item>-->
          <el-form-item label="商家编号">
            <span>{{ business.businessCode }}</span>
          </el-form-item>
          <el-form-item label="商家名称">
            <span>{{ business.businessName }}</span>
          </el-form-item>
          <el-form-item label="法人">
            <span>{{ business.legalPerosn }}</span>
          </el-form-item>
          <el-form-item label="联系人">
            <span>{{ business.contact }}</span>
          </el-form-item>
          <el-form-item label="联系人电话">
            <span>{{ business.contactPhone }}</span>
          </el-form-item>
          <el-form-item label="商铺详细地址">
            <span>{{ business.provincesName+" "+business.cityName+" "+business.areaName+" "+business.businessAddress }}</span>
          </el-form-item>
          <el-form-item label="身份证号码">
            <span>{{ business.idNumber }}</span>
          </el-form-item>
          <el-form-item label="营业执照号码">
            <span>{{ business.licenseNumber }}</span>
          </el-form-item>
          <el-form-item label="主营产品">
            <span>{{ business.mainProducts }}</span>
          </el-form-item>
          <el-form-item label="营业开始时间">
            <span>{{ business.beginHours }}</span>
          </el-form-item>
          <el-form-item label="营业结束时间">
            <span>{{ business.endHours }}</span>
          </el-form-item>
          <el-form-item label="qq号码">
            <span>{{ business.qqNumber }}</span>
          </el-form-item>
          <el-form-item label="邮箱">
            <span>{{ business.email }}</span>
          </el-form-item>
          <el-form-item label="注册时间">
            <span>{{ business.registrationTime }}</span>
          </el-form-item>
          <el-form-item label="商家状态">
            <span>{{ business.businessStatus }}</span>
          </el-form-item>
          <el-form-item label="商家描述">
            <span>{{ business.description }}</span>
          </el-form-item>
          <el-form-item label="评分">
            <span>{{ business.score }}</span>
          </el-form-item>
          <el-form-item label="审核人">
            <span>{{ businessRegistration.reviewer }}</span>
          </el-form-item>
          <el-form-item label="审核时间">
            <span>{{ businessRegistration.reviewTime }}</span>
          </el-form-item>
          <el-form-item label="审核意见">
            <span>{{ businessRegistration.reviewAdvice }}</span>
          </el-form-item>
          <el-form-item label="审核状态">
            <span>{{ businessRegistration.reviewStatus }}</span>
          </el-form-item>
          <el-col :span="20">
            <el-form-item label="商家资料">
              <div v-for="file in fileList">
                <img height="150px" width="200" style="text-align: center;margin-left: 0px"
                     :src="headerFile+file.attachmentAddr" alt="">
                <span style="color: blue;cursor: pointer"
                      @click="down(file.attachmentAddr)">下载</span> <span
                style="color: blue;cursor: pointer" @click="view(file.attachmentAddr)">预览</span>
              </div>

            </el-form-item>
          </el-col>
          <!--<el-form-item label="备注">-->
          <!--<span>{{ businessRegistration.remark }}</span>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="创建人">-->
          <!--<span>{{ businessRegistration.createId }}</span>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="创建时间">-->
          <!--<span>{{ businessRegistration.createDatetime }}</span>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="修改人">-->
          <!--<span>{{ businessRegistration.updateId }}</span>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="修改时间">-->
          <!--<span>{{ businessRegistration.updateDatetime }}</span>-->
          <!--</el-form-item>-->
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
  import {BusinessRegistrationService} from './BusinessRegistrationService';
  import {BusinessService} from "./BusinessService";

  export default {
    components: {},
    data() {
      return {
        businessRegistration: {},
        business: {},
        headerFile: process.env.BASE_FILE_VIEW,
        fileList: null,
        formName: "simple_business",
        files: [],
      }
    },
    methods: {
      view(path) {
        window.open(process.env.BASE_FILE_VIEW + "" + path + '&isOnline=true')
      },
      down(path) {
        window.open(process.env.BASE_FILE_VIEW + "" + path)
      },
      findBusinessRegistrationForView(businessRegistrationId)//查找商家注册
      {
        BusinessRegistrationService.findBusinessRegistrationForView(businessRegistrationId).then((resp) => {
          this.businessRegistration = resp.data;
          this.business = this.businessRegistration.business;
          this.findBusinessForView(this.business.eid);
          console.log( "business",JSON.stringify(this.business.eid))
        }).catch((error) => {
          this.$message({
            type: 'error',
            message: '查询商家注册出错'
          })
        })
      },
      findBusinessForView(businessId)//查找商家
      {
        BusinessService.findBusinessForView(businessId).then((resp) => {
          this.business = resp.data;
          BusinessService.findAllUploadedFilesByIdAndName(businessId, this.formName)
            .then((res) => {
              this.fileList = res.data;
              this.fileList.forEach((file) => {
                BusinessService.downloadAttachments(false, file.attachmentAddr)
                  .then((res) => {
                    console.log("附件下载成功")
                    let File = {};
                    File = file;
                    this.files.push(file);
                  })
                  .catch((err) => {
                    console.log("附件下载失败")
                  })
              })
              console.log("附件读取成功：" + JSON.stringify(this.files))

            })
            .catch((err) => {
              console.log("附件读取失败")
            })
        }).catch((error) => {
          this.$message({
            type: 'error',
            message: '查询商家出错'
          })
        })
      },
    },
    created() {
      const businessRegistrationId = this.$route.params.businessRegistrationId;
      this.findBusinessRegistrationForView(businessRegistrationId);
    },
  }

</script>
<style scoped lang="scss">

</style>
